<route lang="json5">
{
  style: {
    navigationBarTitleText: '格知汇GACC',
    navigationStyle: 'custom',
  },
}
</route>

<template>
  <!-- 富文本浏览器 -->
  <view class="entire">
    <image
      style="z-index: -10; position: fixed; top: 0; width: 100vw; height: 100vh"
      :src="listBg"
      mode="aspectFill"
    ></image>
    <view class="div1">
      <Backbar title="公告详情" />
    </view>
    <view class="div2" :style="{ height: pageData.div2Height + 'px' }">
      <rich-text style="margin-bottom: 80rpx; margin-top: 20rpx" :nodes="pageData.data.content" />
    </view>
  </view>
</template>

<script setup lang="ts">
import { getNoticeDetail, NoticeItem } from '@/service/leftTop/leftTop'
import { listBg } from '@/static/imgMap'

const props = defineProps<{
  data: NoticeItem
  div2Height: number
}>()

const pageData = reactive({
  data: { ...props.data },
  div2Height: props.div2Height,
})

onMounted(() => {
  imgFix()
  uni.getSystemInfo({
    success(res) {
      const screenHeight = res.windowHeight
      console.log(screenHeight)
      uni
        .createSelectorQuery()
        .select('.div1')
        .boundingClientRect((data) => {
          pageData.div2Height = screenHeight - data.height
        })
        .exec()
    },
  })
})

onLoad((options) => {
  // Page navigation parameter reception
  pageData.data = JSON.parse(decodeURIComponent(options.data))
  getNoticeDetail(pageData.data.id).then((response) => {
    pageData.data = response.data
    imgFix()
  })
  console.log(pageData.data)
})

// Image size fix
const imgFix = () => {
  pageData.data.content = pageData.data.content.replaceAll(
    '<img ',
    '<img style="max-width:100%;height:auto"',
  )
}
</script>

<style scoped lang="scss">
.entire {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .div1 {
    width: 100%;
    background: rgb(37, 73, 115);
    .title {
      display: flex;
      position: relative;
      justify-content: center;
      align-items: center;
      background: rgb(37, 73, 115);
      width: 100%;
      height: 120rpx;
      color: #fff;
      font-size: large;
      overflow: hidden; //隐藏文字
      text-overflow: ellipsis; //显示 ...
      white-space: nowrap; //不换行
      padding-left: 20rpx;
      padding-right: 20rpx;
    }
    .toolbar {
      position: relative;
      width: 100%;
      height: 70rpx;
      background-color: #e5effd;
      border-top-left-radius: 30rpx;
      border-top-right-radius: 30rpx;
    }
  }
  .div2 {
    display: flex;
    flex-direction: column;
    width: 700rpx;
    padding-left: 25rpx;
    overflow-y: scroll;
    .title {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      width: 100%;
      font-size: medium;
      margin-top: 50rpx;
      min-height: 200rpx;
    }
  }
}
::-webkit-scrollbar {
  display: none;
}
</style>
